﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ManagerGame
{
    /// <summary>
    /// Basic company class of the game
    /// </summary>
    public class Company : GameObjectBase
    {

        private static int idCounter = 1; // let's start from number one

        /// <summary>
        /// Constructor that increases the value of Id
        /// </summary>
        public Company()
        {
            Happiness = Happiness.Content;
            Income = 500;
            Workers = 1;
            Risk = 1;
            Salary = 30;
            _id = idCounter;

            idCounter++;
        }

        private readonly int _id;
        /// <summary>
        /// Company Id. 
        /// </summary>
        public int Id
        {
            get
            {
                return _id;
            }
        }

        /// <summary>
        /// How happy the workers are.
        /// </summary>
        public Happiness Happiness { get; set; }
        /// <summary>
        /// How much salary the salary costs are per turn
        /// </summary>
        public int Salary { get; set; }
        /// <summary>
        /// Amount of workers
        /// </summary>
        public int Workers { get; set; }
        /// <summary>
        /// Income per turn
        /// </summary>
        public double Income { get; set; }
        /// <summary>
        /// Risk of getting caught
        /// </summary>
        public int Risk { get; set; }
        /// <summary>
        /// Active operations
        /// </summary>
        public ICollection<Operation> Operations { get; set; } 
        /// <summary>
        /// Have the workers recently enjoyed sauna?
        /// </summary>
        /// <returns>True, if the workers are still in awe</returns>
        public bool HaveSauna()
        {
            return Operations.Any(operation => operation.OperationType == OperationType.CompanySauna && operation.RoundsActive > 1);
        }

        /// <summary>
        /// Just for testing
        /// </summary>
        /// <returns>String for testing purposes</returns>
        public string toString()
        {
            // todo: "Pub" should be replaced with the real type enum...
            return "Pub " + this.Id + ", workers: " + this.Workers + ", salary: " + this.Salary;
        }
    }
}
